<?php

namespace app\uniapp\service;

use app\model\store\GoodsCart;
use app\uniapp\service\traits\InstanceTrait;

class GoodsCartService extends UniBaseService
{

    use InstanceTrait;

    function initialize()
    {
        $this->model = new GoodsCart();
    }

    function formatData(array $data): array
    {
        return $data;
    }

    //  当前用户的购物车商品总数
    function getUserTotal(): int
    {
        return GoodsCart::where('site_id', $this->siteId)->where('user_id', $this->userId)->sum("num");
    }
}
